package cn.com.swu.mianyangapp.ui.message;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import cn.com.swu.mianyangapp.R;
import cn.com.swu.mianyangapp.bean.Text;


public class DraftAdapter extends BaseAdapter {

    private List<Text> textList;
    private LayoutInflater inflater;

    public DraftAdapter(List<Text> textlist, ListView listView){

        this.textList=textlist;
        this.inflater=LayoutInflater.from(listView.getContext());
    }
    @Override
    public int getCount() {
        return textList==null?0:textList.size();
    }
    @Override
    public Object getItem(int position) {
        return textList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {

        View view=inflater.inflate(R.layout.item_draft,null);
        Text text=(Text)getItem(position);
        TextView textTitle=(TextView) view.findViewById(R.id.text_Title);
        TextView recvTele=(TextView) view.findViewById(R.id.recv_tele);
        TextView sendTime=(TextView)view.findViewById(R.id.send_time);
        textTitle.setText(text.getTextTitle());
        recvTele.setText(text.getRecvTele());
        sendTime.setText(text.getSendTime());

        ViewHolder viewHolder = (ViewHolder) view.getTag();
        return view;
    }

    class ViewHolder {
        TextView mTextView;
        ImageButton mButton;
    }
}
